package com.lemon.controller;
import com.lemon.domain.PageResult;
import com.lemon.domain.dto.OutboundOrderDetailsDto;
import com.lemon.domain.dto.OutboundOrderDto;
import com.lemon.domain.pageParam.OutboundOrderPageParam;
import com.lemon.service.OutboundOrderService;
import com.lemon.domain.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 出库单表(outbound_order)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/outbound_order")
@RequiredArgsConstructor
public class OutboundOrderController {
    /**
     * 服务对象
     */
    private final OutboundOrderService outboundOrderService;

    @GetMapping("/status")
    public Result getPageByStatus(Integer page ,Integer pageSize,Integer status,String invoiceCode){
        PageResult list = outboundOrderService.getPageByStatus(page,pageSize, status,invoiceCode);
        return Result.success(list);
    }


    @PostMapping
    public Result add(@RequestBody OutboundOrderDto dto) {
        outboundOrderService.add(dto);
        return Result.success();
    }

    @GetMapping
    public Result getPage(OutboundOrderPageParam  param){
        PageResult page = outboundOrderService.getPage(param);
        return Result.success(page);
    }

    @PutMapping
    public Result update(@RequestBody OutboundOrderDetailsDto dto) {
        outboundOrderService.fahuo(dto);
        return Result.success();
    }

}
